﻿function addColumnDependencies(gridId, parentColumn, childColumn, url, loadingText, headingText, dataTextField, dataValueField, nullParentDataValue, onChange) {
    columnDependencies.push({ 
        gridId: gridId,
        parentColumn: parentColumn,
        childColumn: childColumn,
        url: url,
        loadingText: loadingText,
        headingText: headingText,
        dataTextField: dataTextField,
        dataValueField: dataValueField,
        nullParentDataValue: nullParentDataValue,
        onChange: function(rowId, columnDependency) {
            onChange
        } 
    });
}

function addChildColumnDependencies(parentGridId, parentColumn, childColumn, url, loadingText, headingText, dataTextField, dataValueField, nullParentDataValue, onChange) {
    var parentGrid = $("#" + parentGridId);
    var rowIds = parentGrid.jqGrid('getDataIDs');

    for (var i = 0; i < rowIds.length; i++) {
        var subgrid_table_id = parentGridId + '_' + rowIds[i] + '_t';

        addColumnDependencies(subgrid_table_id, parentColumn, childColumn, url, loadingText, headingText, dataTextField, dataValueField, nullParentDataValue, onChange);
    }
}
    

